package two_pointer;
//盛最多水的容器
public class leetcode11 {
    public static void main(String[] args) {
        int[] nums = {1,8,6,2,5,4,15,3,4};
        int results = maxArea(nums);
        System.out.println(results);
    }

    public static int maxArea(int[] height) {
        int results = 0;
        int left = 0;
        int right = height.length - 1;
        results = Math.min(height[left],height[right])*right;
        while(right > left){
            if(Math.min(height[left],height[right])*(right-left) > results){
                results = Math.min(height[left],height[right])*(right-left);
            }
            if(height[left] < height[right]){
                left++;
            }
            else {
                right--;
            }
        }
        return results;
    }
}